package com.pheruagor.handmanager.model.business {
    import flexunit.framework.Assert;
    import flexunit.framework.TestCase;

    import mx.utils.ObjectUtil;
    import mx.utils.UIDUtil;

    public class ClubTest extends TestCase {

        private var m_club:Club;

        override public function setUp():void {
            m_club = new Club();
        }

        public function testSimpleClone():void {
            var id:String = UIDUtil.createUID();
            var name:String = "test";
            var creationDate:Date = new Date(2009, 6, 25, 14);
            m_club.id = id;
            m_club.name = name;
            m_club.creationDate = creationDate;

            var clone:Club = m_club.clone();
            m_club.name = "test modified";
            m_club.id = UIDUtil.createUID();
            m_club.creationDate = new Date(2010, 6, 25, 14);
            Assert.assertEquals(clone.id, id);
            Assert.assertEquals(clone.name, name);
            Assert.assertTrue(ObjectUtil.dateCompare(clone.creationDate, creationDate) == 0);
        }

        public function testNullOrEmptyCompare():void {
            var clubToCompare:Club = new Club();
            Assert.assertTrue(m_club.equals(clubToCompare));

            var id:String = UIDUtil.createUID();
            m_club.id = id;
            clubToCompare.id = id;
            Assert.assertTrue(m_club.equals(clubToCompare));

            var name:String = "test"
            m_club.name = name;
            clubToCompare.name = name;
            m_club.id = null;
            clubToCompare.id = null;
            Assert.assertTrue(m_club.equals(clubToCompare));
        }

        public function testSimpleCompare():void {
            var id:String = UIDUtil.createUID();
            var name:String = "test"
            var creationDate:Date = new Date(2009, 6, 25, 14);
            m_club.id = id;
            m_club.name = name;
            m_club.creationDate = creationDate;

            var clubToCompare:Club = new Club();
            clubToCompare.id = id;
            clubToCompare.name = name;
            clubToCompare.creationDate = creationDate;
            Assert.assertTrue(m_club.equals(clubToCompare));
        }

    }
}